from jinja2 import FileSystemLoader, Environment


loader = FileSystemLoader('templates', encoding='utf-8')
enviroment = Environment(loader=loader)
tpl=enviroment.get_template('vars.conf.tpl')
data={'ip':'1.1.1.1'}
output =tpl.render(data=data)

# 打印模板内容
print(output)